home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-06 / mcmenu.zip / NETBIOS.PAS < prev    next >
Pascal/Delphi Source File  |  1992-02-23  |  3KB  |  116 lines

  1.  
  2. UNIT NetBIOS;
  3. { ver 0.100
  4.          ^^ bug fix
  5.         ^   minor rev
  6.       ^     major rev
  7. { Turbo Pascal 5.5 }
  8. { 0.100 work start nov 25 1991  Tony Bigras  (604) 753-3245 x2588 }
  9. { Public Domain, Absolutly NO liability accepted!                 }
  10. { for use of NetBIOS functions   }
  11. { 0.723 additional checks for netbios
  12.  
  13. }
  14. INTERFACE
  15.  
  16. USES Dos;
  17.  
  18. CONST
  19.   ncbaddname=       $30;
  20.   ncbdelname=       $31;
  21.   ncbreset=         $32;
  22.   ncbadapterstatus= $33;
  23.   ncbsessionstatus= $34;
  24.   ncbaddgroup=      $36;
  25.   ncbcall=          $10;
  26.   ncblisten=        $11;
  27.   ncbhangup=        $12;
  28.   ncbsend=          $14;
  29.   ncbreceive=       $15;
  30.   ncbnetbiosstatus= $7F; { query if netbios loaded }
  31.   postit=           $80; { add to any waitable routine for concurrent action }
  32.   ncbsenddatagram=  $20; { next 4 are guesses }
  33.   ncbrecdatagram=   $21;
  34.   ncbsendbroadcast= $22;
  35.   ncbrecbroadcast=  $23;
  36.  
  37.  
  38. TYPE
  39.   netname = ARRAY[1..16] OF CHAR;
  40.     { Format of name is padded trailing with blanks }
  41.     { with a 0 in 16 }
  42.   nameorbufinfo= RECORD
  43.     CASE BOOLEAN OF
  44.       FALSE: (name: netname); { Network name }
  45.       TRUE: (nextbuflen: WORD; { Length of next buffer in chain }
  46.              nexbufptr: POINTER) { Pointer to next buffer in chain }
  47.     END; { CASE }
  48.  
  49.   ncbtype = RECORD    { NetBIOS Network Control Block }
  50.     command,          { NetBIOS command }
  51.     retcode,          { Return code }
  52.     lsn,              { Logical session number }
  53.     num: BYTE;        { number of local name ie handle }
  54.     bufptr: POINTER;  { to message buffer }
  55.     len: WORD;        { Message buffer length 65535 maximum in session }
  56.     callname:         { Destination name or info about second buffer in }
  57.       nameorbufinfo;  { a CHAIN SEND command . }
  58.     name: netname;    { Source local name }
  59.     rto,              { Receive timeout in half seconds }
  60.     sto: BYTE;        { Send timeout in half seconds }
  61.     post: POINTER;    { Interrupt completion routine address }
  62.     lanadaptnum: 0..1; { Number of lan adapter }
  63.     cmdcomplete: BYTE; { Command complete flag }
  64.     reserved: ARRAY[1..14] OF BYTE; { reserved for NetBIOS }
  65.   END; { ncb }
  66.  
  67.  
  68. VAR
  69.   netbiosactive: BOOLEAN;
  70.  
  71.   PROCEDURE  nbcall(VAR n: ncbtype);
  72.  
  73.   IMPLEMENTATION
  74.  
  75.   PROCEDURE post;  INTERRUPT; { NetBIOS completion routine }
  76.  
  77.   BEGIN { post }
  78.   END; { post }
  79.  
  80.   PROCEDURE  nbcall(VAR n: ncbtype);
  81.   VAR
  82.     reg: registers;
  83.   BEGIN { nbcall }
  84.     reg.ES:= SEG(n);
  85.     reg.BX:= OFS(n);
  86.     reg.AX:= $0100;   { don't know why from some c code }
  87.     INTR($5C,reg);
  88.   END; { nbcall }
  89.  
  90.   PROCEDURE checknetbios;
  91.   VAR
  92.     tvect,tvect2: POINTER;
  93.     ncb: ncbtype;
  94.   BEGIN
  95.  
  96.     { 0.723 }
  97.     GETINTVEC($5C,tvect);
  98.     GETINTVEC($5D,tvect2);
  99.     netbiosactive:= tvect<>tvect2; { tvect2 should have been unimplemented }
  100.  
  101.     IF netbiosactive THEN
  102.     BEGIN
  103.       ncb.command:= ncbnetbiosstatus;
  104.       Nbcall(ncb);
  105.       IF (ncb.retcode<> 35) THEN
  106.         netbiosactive:= FALSE
  107.       ELSE
  108.         netbiosactive:= TRUE;
  109.     END; { maybe active }
  110.   END; { checknetbios }
  111.  
  112. BEGIN { NetBIOS }
  113.   checknetbios;
  114. END. { NetBIOS }
  115.  
  116.